<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>一键安装</title>
    <!-- 样 式 文 件 -->
    <link rel="stylesheet" href="__STATIC__/component/pear/css/pear.css" />
    <link rel="stylesheet" href="__STATIC__/admin/css/other/login.css" />
</head>
<!-- 代 码 结 构 -->
<body background="__STATIC__/admin/images/background2.svg" style="background-size: cover;">
<form class="layui-form" action="javascript:void(0);" style="margin-top: 0px !important;">
    <div class="layui-form-item">
        <img class="logo" src="__STATIC__/admin/images/logo.png" />
        <div class="title">安装 Da Update</div>
        <div class="desc">
            软 件 更 新 版 本 推 送 管 理 程 序
        </div>
    </div>
    <div class="layui-form-item">
        <input placeholder="数 据 库 地 址: " name="host" class="layui-input" value="localhost"  />
    </div>
    <div class="layui-form-item">
        <input placeholder="数 据 库 账 号: " name="dbuser" class="layui-input"  />
    </div>
    <div class="layui-form-item">
        <input placeholder="数 据 库 密 码: " type="password" name="dbpass" class="layui-input"  />
    </div>
    <div class="layui-form-item">
        <input placeholder="数 据 库 名 称 : " name="dbname" class="layui-input"  />
    </div>
    <div class="layui-form-item">
        <input placeholder="数 据 库 端 口: " name="port" class="layui-input" value="3306" />
    </div>
    <div class="layui-form-item">
        <input placeholder="数 据 表 前 缀: " name="prefix" class="layui-input" value="da_" />
    </div>
    <div class="layui-form-item">
        <input placeholder="管 理 员 账 号: " name="username" class="layui-input" />
    </div>
    <div class="layui-form-item">
        <input placeholder="管 理 员 密 码: " name="password" class="layui-input" />
    </div>
    <div class="layui-form-item">
        <button type="button" class="pear-btn pear-btn-success install" lay-submit lay-filter="install">
            一 键 安 装
        </button>
    </div>
</form>
<!-- 资 源 引 入 -->
<script src="__STATIC__/component/layui/layui.js"></script>
<script src="__STATIC__/component/pear/pear.js"></script>
<script>
    layui.use(['form', 'button', 'popup', 'jquery'], function() {
        let form = layui.form;
        let button = layui.button;
        let popup = layui.popup;
        let $ = layui.jquery;

        // 登 录 提 交
        form.on('submit(install)', function(data) {
            let loginBtn = button.load({
                elem: '.install'
            });
            popup.warming("一键安装进行中, 请勿刷新");
            $.ajax({
                type: "POST",
                data: data.field,
                success: function (res) {
                    loginBtn.stop();
                    if (res.code == 0){
                        layer.confirm(res.msg, {
                            btn: ['前往登录'] //按钮
                        }, function(){
                            window.location = "{:url('login/index')}";
                        });
                    } else {
                        popup.failure(res.msg);
                    }
                }, error: function () {
                    loginBtn.stop();
                    popup.failure("失败");
                }
            });
            return false;
        });
    });
</script>
</body>
</html>
